//
//  APPLanchViewController.m
//  DecoAware
//
//  Created by Apple on 2016/12/24.
//  Copyright © 2016年 Sunyoung. All rights reserved.
//

#import "APPLanchViewController.h"
#import "JWTAppTabBarTheme.h"



#define StandarUserDefaults [NSUserDefaults standardUserDefaults]

@interface APPLanchViewController ()
{
    //启动封面 对应的图片
    UIImage *_defaultImage;
    
    //登录按钮
    UIButton *_loginBtn;
    
    UIViewController *_viewController;
}

@property (nonatomic,strong) UIImageView *lanchImageView;

@end

@implementation APPLanchViewController

SHARED_INSTANCE_IMPLEMENTATION(APPLanchViewController);

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.navigationController setNavigationBarHidden:YES];
    //通过背景图片来设置背景
    //UIImage *backgroundImage = [[Common sharedInstance].appTheme  getThemeImageWithName:@"naviBG"]; //
    //[self.navigationController.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];  //设置背景
    
    UIImageView *lanchIV = [[UIImageView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:lanchIV];
    lanchIV.contentMode = UIViewContentModeScaleAspectFill;
    _lanchImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    _lanchImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:_lanchImageView];
    //设置app 封面
    NSString *lachName = [self splashImageNameForOrientation:[UIDevice currentDevice].orientation];
    NSLog(@"lachName=%@",lachName);
    _defaultImage = [UIImage imageNamed:@"LaunchImage"];
    if(lachName)
        _defaultImage = [UIImage imageNamed:lachName];
    lanchIV.image = _defaultImage;
    
//    [self initAppTabBar];
}

-(void) initAppTabBar{
    [[JWTAppTabBarTheme sharedInstance] customizeInterfaceUIColor:HeaderBackground_Color];
    RDVTabBarController *tabbarVC = [[JWTAppTabBarTheme sharedInstance] setupViewControllers];
    [[JWTAppTabBarTheme sharedInstance] customizeTabBarForController:tabbarVC];
    [AppDelegate sharedInstance].window.rootViewController = tabbarVC;
}

/**get the lanch image name*/
- (NSString *)splashImageNameForOrientation:(UIDeviceOrientation)orientation
{
    CGSize viewSize = self.view.bounds.size;
    NSString* viewOrientation = @"Portrait";
    if (UIDeviceOrientationIsLandscape(orientation)) {
        viewSize = CGSizeMake(viewSize.height, viewSize.width);
        viewOrientation = @"Landscape";
    }
    /*
     CFBundleIcons =     {
     CFBundlePrimaryIcon =         {
     CFBundleIconFiles =             (
     AppIcon29x29,
     AppIcon40x40,
     AppIcon57x57,
     AppIcon60x60
     );
     UIPrerenderedIcon = 1;
     };
     };
     */
    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict) {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
            return dict[@"UILaunchImageName"];
    }
    return nil;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
